package com.huatai.datadevelop.thread.task;

import com.huatai.datadevelop.entity.TableManageEntity;
import com.huatai.datadevelop.service.TableManageService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author hecai
 * @description: TODO 调度平台调度方法
 * @date 2022/12/16 11:38
 * @Version 1.0
 */
@Slf4j
@Component
public class ApiDataTask {

    @Autowired
    private TableManageService tableManageService;

    @Autowired
    private ExecutService executService;

    /**
     * 接口任务配置调度信息
     */
	@XxlJob("apiDataTaskRunTask")
    public void runTask(){
		String tableName = XxlJobHelper.getJobParam();
        log.info(tableName + "调度任务开始");
        TableManageEntity entityByTableName = tableManageService.getEntityByTableName(tableName);
        executService.asyncRequestApi(entityByTableName);
        log.info(tableName + "调度任务结束");
    }
}
